package com.smartfactory.sail.controller;


import com.ada.base.common.ApiResponse;
import com.ada.base.common.ControllerResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.smartfactory.sail.config.HeaderWrapper;
import com.smartfactory.sail.constant.header.OperLogEnum;
import com.smartfactory.sail.entity.OperLog;
import com.smartfactory.sail.service.IOperLogService;
import com.smartfactory.sail.vo.PageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王巨壁
 * @since 2019-08-27
 */
@Api(tags = "操作日志")
@RestController
@RequestMapping("/oper-log")
public class OperLogController extends ControllerResponse {
    private IOperLogService iOperLogService;

    public OperLogController(IOperLogService iOperLogService) {
        this.iOperLogService = iOperLogService;
    }

    @HeaderWrapper(OperLogEnum.class)
    @ApiOperation(value = "操作日志列表", notes = "操作日志列表")
    @PostMapping("OperLogList/{currentPage}/{size}/{sortType}/{sortField}")
    public ApiResponse<IPage<OperLog>> contractOrderList(@RequestBody Map<String, Object> queryParam,
                                                         @PathVariable("currentPage") Long currentPage,
                                                         @PathVariable("size") Integer size,
                                                         @PathVariable("sortType") Integer sortType,
                                                         @PathVariable("sortField") String sortField) {

        PageParam pageParam = new PageParam(currentPage, size, sortType, sortField);
        return ok(iOperLogService.getOperLogPage(pageParam, queryParam));
    }
}
